-
Notifications
You must be signed in to change notification settings - Fork 39
fix: ensure default space creation when skipping onboarding (fixes #150) #158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: ensure default space creation when skipping onboarding (fixes #150) #158
Conversation
WalkthroughIntroduces handleSkip logic for onboarding: when skipping, creates a default space if no spaces exist and a main profile is present, else advances. Updates createSpace to accept an optional name and consistently locate/activate the created space. Re-routes relevant UI actions to handleSkip and standardizes space activation and auto-advance. Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant UI as CreateSpace UI
participant Store as Space/Profile Store
User->>UI: Click "Skip" or "Continue"
UI->>Store: Check mainProfile, list spaces
alt mainProfile exists AND no spaces
UI->>Store: createSpace(DEFAULT_SPACE_NAME)
Store-->>UI: spaceId
UI->>Store: setActiveSpaceId(spaceId)
UI->>UI: auto-advance after 1s
else
UI->>UI: advance to next step
end
sequenceDiagram
actor User
participant UI as CreateSpace UI
participant Store as Space/Profile Store
User->>UI: Click "Create Space"
UI->>Store: createSpace(name or spaceName)
Store-->>UI: space created
UI->>Store: find space by used name
alt found
UI->>Store: setActiveSpaceId(id)
UI->>UI: mark success, auto-advance after 1s
else
UI->>UI: show error
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Assessment against linked issues
Poem
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🔭 Outside diff range comments (3)
src/renderer/src/components/onboarding/stages/initial-space/create.tsx (3)
233-239: Avoid duplicate skip buttons and gate bottom “Skip” on known-no-spacesIn the “Main Profile Not Found” view, there’s already a Skip & Continue button; the bottom Skip also renders, duplicating the action. Also, it should show only when we definitively know there are zero spaces.
Apply both tweaks:
- Require mainProfile to exist.
- Require hasSpaces to be definitively false (not unknown).
Outside this range (the condition line above this block):
-{/* Bottom skip button - only show when in setup mode and not in error/success states */} -{!isLoading && !errorMessage && !hasSpaces && !createSuccess && ( +{/* Bottom skip button - show only when we definitively know there are no spaces */} +{!isLoading && errorMessage === null && hasSpaces === false && !!mainProfile && !createSuccess && (
205-217: Avoid lambda in onClick; pass handler directlyMinor nit: no need to wrap createSpace in an arrow. Pass the function directly to avoid re-creating a closure on each render.
-<Button - onClick={() => createSpace()} +<Button + onClick={createSpace}
61-100: Trim and Validate Space Name in createSpace to Prevent Blank Entries and Matching ErrorsIn
src/renderer/src/components/onboarding/stages/initial-space/create.tsx(around lines 61–100), enhance thecreateSpacehelper to:• Trim the input (either the
nameargument or thespaceNamestate) and bail out on empty/whitespace-only names.
• When searching for the newly created space, compare against the trimmed name to avoid lookup failures.Proposed diff:
--- a/src/renderer/src/components/onboarding/stages/initial-space/create.tsx @@ -62,7 +62,11 @@ const createSpace = async (name?: string) => { - // Use the provided name or the current spaceName - const spaceToCreate = name || spaceName; + // Use the provided name or the current spaceName (trimmed) + const rawName = name ?? spaceName; + const spaceToCreate = rawName.trim(); + if (!spaceToCreate) { + setErrorMessage("Please enter a space name."); + setIsCreating(false); + return; + } // Create the space with just the name @@ -85,7 +89,7 @@ const createSpace = async (name?: string) => { - // Get all spaces to find the one we just created - const newSpace = spaces.find((s) => s.name === spaceToCreate); + // Locate the new space by trimmed name + const newSpace = spaces.find((s) => s.name.trim() === spaceToCreate);Optional: If
flow.spaces.createSpacealready returns the new space’s ID, you can skip the refetch and lookup and callsetActiveSpaceIdimmediately.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
src/renderer/src/components/onboarding/stages/initial-space/create.tsx(8 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)
**/*.{js,jsx,ts,tsx}: Usebun <file>instead ofnode <file>orts-node <file>
Bun automatically loads .env, so don't use dotenv.
UseBun.serve()for HTTP servers and WebSockets instead ofexpress.
Usebun:sqlitefor SQLite instead ofbetter-sqlite3.
UseBun.redisfor Redis instead ofioredis.
UseBun.sqlfor Postgres instead ofpgorpostgres.js.
Use built-inWebSocketinstead ofws.
PreferBun.fileovernode:fs's readFile/writeFile.
UseBun.$for shell commands instead of execa.
Files:
src/renderer/src/components/onboarding/stages/initial-space/create.tsx
**/*.{js,jsx,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)
Import .css files directly in .tsx, .jsx, or .js files and it works with Bun.
Files:
src/renderer/src/components/onboarding/stages/initial-space/create.tsx
🧬 Code Graph Analysis (1)
src/renderer/src/components/onboarding/stages/initial-space/create.tsx (1)
src/renderer/src/components/settings/sections/spaces/space-dialogs.tsx (2)
CreateSpaceDialogProps(56-66)CreateSpaceDialog(68-141)
🔇 Additional comments (1)
src/renderer/src/components/onboarding/stages/initial-space/create.tsx (1)
160-165: Wiring skip actions through handleSkip: good consolidationRouting the “Main Profile Not Found” and “Spaces Already Set Up” paths through handleSkip keeps the onboarding flow consistent.
Also applies to: 174-179
What This PR Does
Testing Instructions
Related Issue
Fixes #150
Summary by CodeRabbit
New Features
Bug Fixes